package com.ymatou.iapi.liveseller.testcase;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.liveseller.parameter.CreateSellerLiveBean;
import com.ymatou.iapi.liveseller.parameter.QueryLiveSimpleStatusBean;
import com.ymatou.iapi.liveseller.service.QueryLiveSimpleStatusCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.LiveRoomCallService;
import com.ymttest.database.model.LiveRoom;
/**
*查询直播间状态
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_QueryLiveSimpleStatus{
	private static QueryLiveSimpleStatusBean querylivesimplestatusBean;
	private static QueryLiveSimpleStatusCall querylivesimplestatusCall;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("查询直播间状态");
	}

	@Before
	public void caseUp() {
		querylivesimplestatusBean=new QueryLiveSimpleStatusBean();
		querylivesimplestatusCall=new QueryLiveSimpleStatusCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(querylivesimplestatusCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_QueryLiveSimpleStatus_001() {
		Logger.start(true,"查询直播间状态成功NotExist0");
		try {
			querylivesimplestatusBean.setLiveId(Integer.MAX_VALUE);
			querylivesimplestatusCall.setData(querylivesimplestatusBean);
			querylivesimplestatusCall.callService();			
			Logger.verifyEquals("200",querylivesimplestatusCall.getString("Code"),"验证code");
			Logger.verifyEquals(0, querylivesimplestatusCall.getJsonObject().get("Data").getAsJsonObject().get("LiveStatus").getAsInt(),"验证LiveStatus");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_QueryLiveSimpleStatus_002() {
		Logger.start(true,"查询直播间状态成功PreView10");
		try {
			CreateSellerLiveBean initcreatebean = LiveRoomCallService.initCreatesellerliveBean(null);
			LiveRoom livedto = LiveRoomCallService.CreateSellerLive(initcreatebean);
			Integer liveroomid = livedto.getId();
			querylivesimplestatusBean.setLiveId(liveroomid);
			querylivesimplestatusCall.setData(querylivesimplestatusBean);
			querylivesimplestatusCall.callService();			
			Logger.verifyEquals("200",querylivesimplestatusCall.getString("Code"),"验证code");
			Logger.verifyEquals(10, querylivesimplestatusCall.getJsonObject().get("Data").getAsJsonObject().get("LiveStatus").getAsInt(),"验证LiveStatus");
			//其他case 会修改开始结束时间 时间校验只放在这里验证
			Logger.verifyEquals(livedto.getStartTime(), querylivesimplestatusCall.getJsonObject().get("Data").getAsJsonObject().get("StartTime").getAsString(),"验证StartTime");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_QueryLiveSimpleStatus_003() {
		Logger.start(true,"查询直播间状态成功InProccess20");
		try {
			CreateSellerLiveBean initcreatebean = LiveRoomCallService.initCreatesellerliveBean(null);
			LiveRoom livedto = LiveRoomCallService.CreateSellerLive(initcreatebean);
			Integer liveroomid = livedto.getId();
			LiveRoomCallService.UpdateLiveTimeToStart(livedto.getId());
			LiveRoomCallService.SellerLiveOnline(livedto.getId(), livedto.getUserId());
			querylivesimplestatusBean.setLiveId(liveroomid);
			querylivesimplestatusCall.setData(querylivesimplestatusBean);
			querylivesimplestatusCall.callService();			
			Logger.verifyEquals("200",querylivesimplestatusCall.getString("Code"),"验证code");
			Logger.verifyEquals(20, querylivesimplestatusCall.getJsonObject().get("Data").getAsJsonObject().get("LiveStatus").getAsInt(),"验证LiveStatus");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_QueryLiveSimpleStatus_004() {
		Logger.start(true,"查询直播间状态成功Close30");
		try {
			CreateSellerLiveBean initcreatebean = LiveRoomCallService.initCreatesellerliveBean(null);
			LiveRoom livedto = LiveRoomCallService.CreateSellerLive(initcreatebean);
			Integer liveroomid = livedto.getId();
			LiveRoomCallService.SysCloseLive(liveroomid);
			querylivesimplestatusBean.setLiveId(liveroomid);
			querylivesimplestatusCall.setData(querylivesimplestatusBean);
			querylivesimplestatusCall.callService();			
			Logger.verifyEquals("200",querylivesimplestatusCall.getString("Code"),"验证code");
			Logger.verifyEquals(30, querylivesimplestatusCall.getJsonObject().get("Data").getAsJsonObject().get("LiveStatus").getAsInt(),"验证LiveStatus");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_QueryLiveSimpleStatus_005() {
		Logger.start(true,"不输入id失败");
		try {
//			querylivesimplestatusBean.setLiveId(Integer.MAX_VALUE);
			querylivesimplestatusCall.setData(querylivesimplestatusBean);
			querylivesimplestatusCall.callService();			
			Logger.verifyEquals("500",querylivesimplestatusCall.getString("Code"),"验证code");
//			Logger.verifyEquals(0, querylivesimplestatusCall.getJsonObject().get("Data").getAsJsonObject().get("LiveStatus").getAsInt(),"验证LiveStatus");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}